// Date
function date (format, timestamp) {
    var that = this,
      jsdate,
      f,
      txt_words = ["Dom", "Lun", "Mar", "Mie", "Jue", "Vie", "Sab", "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"],
      formatChr = /\\?(.?)/gi,
      formatChrCb = function (t, s) {
        return f[t] ? f[t]() : s;
      },
      _pad = function (n, c) {
        n = String(n);
        while (n.length < c) {
          n = '0' + n;
        }
        return n;
      };
  f = {
    d: function () {
      return _pad(f.j(), 2);
    },
    D: function () {
      return f.l().slice(0, 3);
    },
    j: function () {
      return jsdate.getDate();
    },
    l: function () {
      return txt_words[f.w()] + 'day';
    },
    N: function () {
      return f.w() || 7;
    },
    S: function(){
      var j = f.j(),
        i = j%10;
      if (i <= 3 && parseInt((j%100)/10, 10) == 1) {
        i = 0;
      }
      return ['st', 'nd', 'rd'][i - 1] || 'th';
    },
    w: function () {
      return jsdate.getDay();
    },
    z: function () {
      var a = new Date(f.Y(), f.n() - 1, f.j()),
        b = new Date(f.Y(), 0, 1);
      return Math.round((a - b) / 864e5);
    },
    W: function () {
      var a = new Date(f.Y(), f.n() - 1, f.j() - f.N() + 3),
        b = new Date(a.getFullYear(), 0, 4);
      return _pad(1 + Math.round((a - b) / 864e5 / 7), 2);
    },
    F: function () {
      return txt_words[6 + f.n()];
    },
    m: function () {
      return _pad(f.n(), 2);
    },
    M: function () {
      return f.F().slice(0, 3);
    },
    n: function () {
      return jsdate.getMonth() + 1;
    },
    t: function () {
      return (new Date(f.Y(), f.n(), 0)).getDate();
    },
    L: function () {
      var j = f.Y();
      return j % 4 === 0 & j % 100 !== 0 | j % 400 === 0;
    },
    o: function () {
      var n = f.n(),
        W = f.W(),
        Y = f.Y();
      return Y + (n === 12 && W < 9 ? 1 : n === 1 && W > 9 ? -1 : 0);
    },
    Y: function () {
      return jsdate.getFullYear();
    },
    y: function () {
      return f.Y().toString().slice(-2);
    },
    a: function () {
      return jsdate.getHours() > 11 ? "pm" : "am";
    },
    A: function () {
      return f.a().toUpperCase();
    },
    B: function () {
      var H = jsdate.getUTCHours() * 36e2,
        i = jsdate.getUTCMinutes() * 60,
        s = jsdate.getUTCSeconds();
      return _pad(Math.floor((H + i + s + 36e2) / 86.4) % 1e3, 3);
    },
    g: function () {
      return f.G() % 12 || 12;
    },
    G: function () {
      return jsdate.getHours();
    },
    h: function () {
      return _pad(f.g(), 2);
    },
    H: function () {
      return _pad(f.G(), 2);
    },
    i: function () {
      return _pad(jsdate.getMinutes(), 2);
    },
    s: function () {
      return _pad(jsdate.getSeconds(), 2);
    },
    u: function () {
      return _pad(jsdate.getMilliseconds() * 1000, 6);
    },
    e: function () {
      throw 'Not supported (see source code of date() for timezone on how to add support)';
    },
    I: function () {
      var a = new Date(f.Y(), 0),
        c = Date.UTC(f.Y(), 0),
        b = new Date(f.Y(), 6),
        d = Date.UTC(f.Y(), 6);
      return ((a - c) !== (b - d)) ? 1 : 0;
    },
    O: function () {
      var tzo = jsdate.getTimezoneOffset(),
        a = Math.abs(tzo);
      return (tzo > 0 ? "-" : "+") + _pad(Math.floor(a / 60) * 100 + a % 60, 4);
    },
    P: function () {
      var O = f.O();
      return (O.substr(0, 3) + ":" + O.substr(3, 2));
    },
    T: function () {
      return 'UTC';
    },
    Z: function () {
      return -jsdate.getTimezoneOffset() * 60;
    },
    c: function () {
      return 'Y-m-d\\TH:i:sP'.replace(formatChr, formatChrCb);
    },
    r: function () {
      return 'D, d M Y H:i:s O'.replace(formatChr, formatChrCb);
    },
    U: function () {
      return jsdate / 1000 | 0;
    }
  };
  this.date = function (format, timestamp) {
    that = this;
    jsdate = (timestamp === undefined ? new Date() :
      (timestamp instanceof Date) ? new Date(timestamp) :
      new Date(timestamp * 1000)
    );
    return format.replace(formatChr, formatChrCb);
  };
  return this.date(format, timestamp);
}
// Date

// Time
function time () {
  return Math.floor(new Date().getTime() / 1000);
}
// Time

// Explode
function explode (delimiter, string, limit) {
  if ( arguments.length < 2 || typeof delimiter === 'undefined' || typeof string === 'undefined' ) return null;
  if ( delimiter === '' || delimiter === false || delimiter === null) return false;
  if ( typeof delimiter === 'function' || typeof delimiter === 'object' || typeof string === 'function' || typeof string === 'object'){
    return { 0: '' };
  }
  if ( delimiter === true ) delimiter = '1';
  delimiter += '';
  string += '';
  var s = string.split( delimiter );
  if ( typeof limit === 'undefined' ) return s;
  if ( limit === 0 ) limit = 1;
  if ( limit > 0 ){
    if ( limit >= s.length ) return s;
    return s.slice( 0, limit - 1 ).concat( [ s.slice( limit - 1 ).join( delimiter ) ] );
  }
  if ( -limit >= s.length ) return [];
  s.splice( s.length + limit );
  return s;
}
// Explode

// UCWords
function ucwords (str) {
  return (str + '').replace(/^([a-z\u00E0-\u00FC])|\s+([a-z\u00E0-\u00FC])/g, function ($1) {
    return $1.toUpperCase();
  });
}
// UCWords